package com.situ.stmall.manager.service.impl;

import com.situ.stmall.manager.entity.GoodsPic;
import com.situ.stmall.manager.mapper.GoodsPicMapper;
import com.situ.stmall.manager.service.GoodsPicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GoodsPicServiceImpl implements GoodsPicService{
    @Autowired
    private GoodsPicMapper goodsPicMapper;

    /**
     * 批量添加
     *
     * @param pics
     * @return
     * @throws Exception
     */
    @Override
    @Transactional(
            propagation = Propagation.REQUIRED
    )
    public int addPatch(List<GoodsPic> pics) throws Exception {
        return goodsPicMapper.insert(pics);
    }

    /**
     * 根据商品id删除
     *
     * @param goodsId
     */
    @Override
    public int removeByGoodsId(Integer goodsId) throws Exception {
        return goodsPicMapper.deleteByGoodsId(goodsId);
    }
}
